package com.example.e.Adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.example.e.Bean.GoodsBean
import com.example.e.R

class SubmitProductAdapter (val submit_list:List<GoodsBean>):
    RecyclerView.Adapter<SubmitProductAdapter.SubmitProductViewHolder>() {

    class SubmitProductViewHolder(view: View): RecyclerView.ViewHolder(view){
        val tv_submit_name: TextView = view.findViewById(R.id.tv_submit_name)
        val tv_submit_price: TextView = view.findViewById(R.id.tv_submit_price)
        val tv_submit_count: TextView = view.findViewById(R.id.tv_submit_count)
    }


    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): SubmitProductViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.elem_product_submit,parent,false)
        return SubmitProductViewHolder(view)
    }

    override fun onBindViewHolder(holder: SubmitProductViewHolder, position: Int) {

            val info = submit_list[position]
            holder.tv_submit_name.text = "${info.title}"
            holder.tv_submit_price.text = "${info.price}"
            holder.tv_submit_count.text = "${info.num}"

    }
    override fun getItemCount() = submit_list.size
}
